package com.atguigu07.toString;

import java.util.Date;

/**
 * ClassName: ToStringTest
 * Package: com.atguigu07.toString
 * Description:
 *
 * @Author ZY
 * @Create 21:41
 * @Version 1.0
 */
public class ToStringTest {

    public static void main(String[] args) {
        User u1 = new User("Tom",12);
        System.out.println(u1.toString());//com.atguigu07.toString.User@b4c966a

        String s1 = new String("hello");
        System.out.println(s1.toString());//hello

        Date date = new Date();
        System.out.println(date);

    }
}


class User{

    String name;
    int age;

    public User(){}

    public User(String name,int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String toString(){
        return "User{" + "name='" + name + '\'' + ", age=" + age + '}';
    }
}



